﻿using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;


public class CardAnimationController : MonoBehaviour
{
    [SerializeField]
    private Vector3 _targetLocation = Vector3.zero;

    [Range(0.0f, 10.0f), SerializeField] 
    private float _moveDuration = .2f;
    // Start is called before the first frame update

    [SerializeField] private Ease _moveEase = Ease.Linear;

    [SerializeField] private DoTweenType _doTweenType = DoTweenType.Hover;
    private DragCard dragCard;
    
    private enum DoTweenType
    {
        Hover,
        Deck
    }
    
    void Start()
    {
        dragCard = GetComponent<DragCard>();
    }

//    public void PlayOnHoverAnimation()
//    {
//        PlayCardAnimation(dragCard.GetHoverAnimationSet());
//    }
//
//    public void PlayOnDeckAnimation()
//    {
//        PlayCardAnimation(dragCard.GetDeckAnimationSet());
//    }

    public void PlayCardAnimation(AnimationSet targetAnimationSet)
    {
        if (DOTween.IsTweening(transform))
        {
            transform.DOPause();
        }
        
        transform.DORotateQuaternion(targetAnimationSet.rot, _moveDuration).SetEase(_moveEase);
        transform.DOMove(targetAnimationSet.pos, _moveDuration).SetEase(_moveEase);
        transform.DOScale(targetAnimationSet.scale, _moveDuration).SetEase(_moveEase);
    }
}
